Skip to main content

Full text of "Arduino"

See other formats

Aquaponics - Online Temperature and Humidity 


Make Projects 

build, hack, tweak, share, discover,' 

Aquaponics - Online 

Temperature and Humidity 

Written By: lAquaponics 


Arduino Uno R3 (1) 

LED. 2-lead bicolor (1) 

1/4W470ohm resistor (1) 

1/4W 4.7k ohm resistor (1) 


Breadboard jumper wires, or solid core 22AWG wire (1) 

Small Breadboard (1) 

Arduino Ethernet Shield (1) 

Arduino Power Cord (1) 


This project is a part of the Arduino Data Acquisition and Control System described in the 
upcoming book Automating Aquaponics with Arduino . 

While this project is designed with aquaponics in mind, it does not require an aquaponic 
system, making it useful for other projects such as home automation. The included 
application is, therefore, bare-bones, making it easier to integrate into any other application 

© Make Projects Page 1 of 9 

Aquaponics - Online Temperature and Humidity 

Every sixty seconds, the Arduino will test its connection to App Engine. The return should be 
"Ok", which is parsed by the Arduino. If the connection is ok, the bicolor LED is set to green, 
otherwise it is set to red. If the connection is good, the Arduino will take a reading from 
digital pin six (the DHT pin) and create a GET request to App Engine. App Engine will query 
the datastore (its database) for the Environment entity, update the temperature and relative 
humidity values and put the entity back in the datastore. 

On startup, the web browser (client) will create a temperature and humidity gauge with 
values at zero. It will then make an AJAX request to the datastore which will return a JSON 
array. The client parses the array and updates the gauges. Finally, it sets an interval to 
repeat the process, giving you an updated display. 

Software Versions: 

1. Arduino IDE: Arduino-1.0.3 

2. App Engine SDK: Python, Linux, 1.7.4 

3. Python: Python2.7 

4. Ubuntu 12.04 

5. Simon Monk's Arduino Timer library 

6. Adafruit's DHT Arduino library 

© Make Projects Page 2 of 9 

Aquaponics - Online Temperature and Humidity 

glthub Explore GitHub Search Features Blog 

Sign up tor free 

Sign In 

JChristensen / Timer 



Pull Requests 


• Star 6 p Fork 


A rofK of SHmon Monies Aroulno Timet library — Read mofe 

http ; tlsim on k, bl eg sp m r201 2/0 1 tardul n o*tl mer-l Ibrary. htm I 

<£> ZIP http ssh GitRead.Oniy hups://'glthui).cosi/Xnrist:erisen/Tinier .git 

|^, ReaaxQnly access 

p branch: master 

Files Commits Branches 1 

Timer/ S 

1.1 Data type and otrier changes. 

JChftstensen authored a year ago 

M examples 

a year ago 

[^ Event.cpp 

a year ago 

S Event.h 

a year ago 

Hi ReadMe.txt 

a year ago 

H Tlmer.cpp 

a year ago 

ID rimBr.h 

a year ago 

§) keywofds.txl 

a year ago 

Library as downloaded Q2Feb2Di2 22: SS UTC [JChnsiensenj 

1.1 Datatype and other changes. [JChnstQnsei] 

1.1 Data type and other changes. [JChristensenJ 

1.1 Datatype and other changes, [JChnstensen] 

1.1 Datatype and other cnanges. [JChnstGnsen] 

1.1 Datatype and other changes. [JChristensenJ 

1.1 Data type and other changes. (JChhstensenJ 


© 2 commit! 

latest commit. 35e66b&cfc |§. 

• Install Simon Monk's Timer library 

Step 2 

Explore GitHub Search Features Blog 

Sign up for free 

Sign In 

jQ adafruit/DHT-sensor-library * star « p Fork 


Code Network Pull Requests Issues 1 Graphs 

http:Ww¥m.lady3d3,neL r le3rn^er5orSj , dhtrilrTil 

Q fflP http SSH Git Read-Only http5://github.ccnn/arJafru±t/DHT-sensor-library.git |fe Read-Only Access 

p branch: master 



Commits Branches i 


DHT-sensar-l library / B 

© 14 commits 

Merge pull request 


scerup/master — 

I lady a da authared 2 months ago 

latest commit 26e2bcld79 [|iL- 

■ examples 

2 years ago 

claimed the puiiup [ladyada] 

II DHT.cpp 

2 months ago 

Support tor non 16fnhj2 devices [soerup] 

1 DHT.h 


2 months ago 
2 years ago 

Support for non ifimriz devices [soerup] 
added mini readme [ladyada] 

l^i README.txt 

This is an Arduino library for the dht series of low cost temperature/humidity 

• Install Adafruit's DHT library . 

• Make sure the DHT library is 
named "DHT". 

© Make Projects 

Page 3 of 9 

Aquaponics - Online Temperature and Humidity 

© Make Projects Page 4 of 9 

Aquaponics - Online Temperature and Humidity 

(application: ,1^1 ,U 'l-V J j:i | 
version: 1 
ru nt imE : pyt hon27 
api_version : 1 

threadsafe: true 


* ■deferred: on 


- url: /Static 
static_dir: static 

■> url: /adacs/.* 

- url: /.* 
script: *ain,app 
Login: admin 

ne: 1 Col: 24 

Find: myapsystem 

INS LINE UTF-S app.yaml 

Replace; your-project-name 

• If you don't already have a Google 
account, sign-up for one. 

• For App Engine, you will need a 
developer's account so sign-up for 

• Next, download the App Engine 
SDK. The version used here was 

• In the App Engine Admin Console, 
create a new project. The final URL 
for the project name will be: 
Also, take note of the login 
security. You can choose Google 
Accounts, Google Apps for 
Business Domain, or OpenlD. 

• Download the project tar file and 
extract it in your home directory 
(Ubuntu). Inside you will find the 
GAE directory labelled 
myapsystem and the Arduino folder 
containing the Arduino file.] 

• Go into the myapsystem directory 
and open "app.yaml". On the first 
line you will see the application 
name. Replace this name with the 
name of your project. See picture. 

• One final note on security. At the 
bottom of the "app.yaml" file you 
will see that the script "main. app" 
requires admin to login, but no 
other script says this. This 
application is not secure beyond 
the first page. A thorough 
discussion on security is outside 

© Make Projects 

Page 5 of 9 

Aquaponics - Online Temperature and Humidity 

the scope of this project, but be 



• To launch the GAE SDK, open up a terminal and type: "python2.7 
AppEngine/ IAquaponics_DHT/myapsystem". If you renamed the project 
folder, or put it outside your home directory, change the path accordingly. 

• Launch a web browser and go to: "http://localhost:8080/". If all went well, you should see a 
login prompt. Click the checkbox "Login as administrator" and login. The email address 
doesn't matter. 

• At this point you should see two gauges that read zero. To make sure everything is 
working, we are going to replicate the call the Arduino will make. In the browser, type in: 
"http://localhost:8080/adacs/dht?Temp=69.1&RH=24.8". This will present a page that says, 

• Now go back to the previous screen and you should see the gauges update. Ideally, you 
should see figure three. 

© Make Projects 

Page 6 of 9 

Aquaponics - Online Temperature and Humidity 

If all went well, it's time to upload the webapp to GAE. From the command line, change 
directories into your GAE folder and type: "./ update 
~/IAquaponics_DHT/myapsystem". Again, substitute your path. 

You will probably be prompted to login with your email and password. 

When the update has done, go to your webapp: "" . If you 
are not already logged in, you will log in to Google normally. Finally, you will see the home 

If your gauges are zero, go ahead and fake the Arduino call again, and return back to the 
home page. It should look the same as the localhost app. 

Step 6 


IS ' ]USB / 



■ / / 


3 i Li 

•ft ?/. SH331D 
•a. f a. a. a. 




* O # + + *f-f-f + ♦//♦ t 

nun . *r in i no . it 

I £ 3 1 S 

*-f+ * * * ■ ■ # ft * * 


^ ************************ 


Wire up your breadboard as shown 
in the Fritzing diagram. Please 
note, the Ethernet shield is not 
shown, but the jumper wires plug 
into the Ethernet Shield which 
resides on top of the Arduino. 

© Make Projects 

Page 7 of 9 

Aquaponics - Online Temperature and Humidity 

ll-rf'.^i -or b 

■*!:.., l"^m + 
ralui MTrMHl± 

■■■ IMf Lirlic-I 
•■■ *..|r||« 


• ■' *•-:»■• i- mL M:>iih r*f p** M»in4.1 

■I'Vn 1 .' i"-b! lI|bI*i *■•« bW r* 

. 1—1:1*1 •». ^»J ■!>«■ 9i=* 
■ ■■ irlMI - [ IK. Ml. 1. ai. 
lit »IM|I I ■> < L+J. n I . a }. 

M< t»™*MI ■ "M-i iam ^HQBMf 

IM#MltlUM ElbUI 

■:.r id^l 4 

b.u ,. runji. 

j< inn lnwut 

l"--'ll-l'-!»K. -Pl' *-<— Tl 

> ■ IMWX 

j.15 ; 

*w| l»: -i: 

*i --t-;i-n. 


l <i'iHni. *n"ilra.nvl. 

.: "+-#-1 * 


tt*W ■■ I 

tain,! :-|--"-3cwtfl. 

Iflruq 4WAKILM ■ "l 
riMUilldft ■^{'Mlijf 

: ' rq ^ 1 » r 
|i ftPWIIC — > I I 

"i'H&MMQM^tiifr i>l, 

■ .i^ M M Him jt -=.-1 

I 1' ip [ 
04111 ^i*h4cwmcmcnJ0. ,rn. 


■ I 1 T ff ' 

II :i"^r.1l II i-wlYil I 

wU s ';-i{ - v.i "|. 
**i hi E'nii'i 

,M -I 

,- Imbi - -:Ki en ei ■»< te-li. 

■ -44I • dlnli-l jlCMf 3 L. lHt.HPJ 
.>■ J 4lnl-i:-. 1 1. r*. ■.!>!. 

■-'►■•; 1 

c -^:»-ii .--i 

I ipMpti em rate »,■*■■ lis-- + tnp + -itr^ + 41. t"»r I 

. 1 ►:■■:>:.■■: - 

■ ■■c ri iiiim' - ! 
.' . 1 II llv-1 ■■■■! 1 ■ ;| r t|* 
1^ ■ ■ -tllBi.reaini 

.ni'Li' : -- 1 »- 1 -: 1 ; ■_■ hi **» >«ip 

■ ■<!!•*■ ••>. I etutw * ■« <"■ 

4 * ?'1P"I ■ ■■ H"! 1 1 

Load the Arduino file. Select Arduino Uno board and your serial port. 

Now, amend the Arduino file with your project name. There are three locations where the 
URL is mentioned. Change ONLY your project name. In the default case, the project is 
called "myapsystem". When you change the URL, do NOT change the "" 
part, only the project name. There are three places where it must change. 

Save and upload the Arduino code. Optionally, it would be helpful to open a serial monitor. 
Also open your app's home page and watch the gauges change. 

© Make Projects 

Page 8 of 9 

Aquaponics - Online Temperature and Humidity 

Note: It may take the Arduino a few tries to connect if there are no instances of your app 
already running. 

There is a flaw with this code, whose remedy wasn't included. This was to ease integration 
into existing apps. Basically, if the Arduino were to stop communicating, you wouldn't know 
without looking at the log in your Admin Dashboard. The gauges would stay the same. 

The solution was to create a timestamp every time the Arduino contacted GAE. A deferred 
task was created for five minutes later. 

After the five minutes, the task would evaluate its current time to the timestamp of the 
Arduino's last contact. 

If that time exceeded double the Arduino's normal contact time interval (60 s => 120s), an 
email alert would be created to notify the user of the connection loss and the values would 
return to zero. 

If you incorporate this into your own project, send us a screenshot, we'd love to see it. 

This document was last generated on 201 3-02-20 1 1 :26:1 9 AM. 

© Make Projects 

Page 9 of 9